/************************新后台js*********************************/
define(function(require) {
	
	var $ = require('jquery1.7');
	var utils = require("utils");
	var ctx = utils.constants.ctx;

	var internalEmailService = require("bean/internalEmailService");
	var Confirmbox = require("confirmbox");
	var Validator = require("validator");
	
	var BlackBox = require("blackbox");
	var blackBox = new BlackBox();
	
	var loginUserId=$("#loginUserId").val();
	
	$(".addLinkMan").bind("click",function(){
		var name = $(".am-form-field").val();
		if(name==null||name==""){
			blackBox.alert("请输入用户账号!!!");
			return;
		}

		var result = internalEmailService.findUserByUserName(name);
	
		if(result.length==0){
			blackBox.alert("该用户不存在!!!");
		}else{
			var userId = loginUserId;
			var linkManId = result[0].id;
			var linkName = result[0].username;
			var linkNickName = result[0].nickname;
			
			var linkMan={
					userId : userId,
					linkManId : linkManId,
					linkName : linkName,
					linkNickName : linkNickName
			}
			
			internalEmailService.linkManAdd(linkMan);
			blackBox.alert("添加成功!!!");
			location=location;
		}
	});
	
	$(".linkManDelete").bind("click",function(){
		var userId = loginUserId;
		var linkManId = $(this).parent().parent().parent().attr("data");
		internalEmailService.linkManDelete(userId,linkManId);
		blackBox.alert("删除成功!!!");
		location=location;
	});
	
});



